#!/bin/bash
SERVICE_NAME=my_service
PID_FILE=/tmp/my_service.pid
JAR_FILE=OffcnStudentManageAPI-0.1-SNAPSHOT.jar

start(){
         nohup java -jar $JAR_FILE 2>&1 > logfile.txt &
         pid=$!
         echo "$pid" >  $PID_FILE
         echo "Starting $SERVICE_NAME"
}

stop(){
        kill `cat $PID_FILE`
        echo "Stoping $SERVICE_NAME"
        rm -rf $PID_FILE
}

restart(){
        stop
        start
}

case $1 in
        start)
                start
                ;;
        stop)
                stop
                ;;
        restart)
                restart
                ;;
        *)
         echo "Usage: $0 start|stop|restart"
         exit 1
         ;;
esac
